﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;

/// <summary>
/// will contain the methods for validatinng user
/// </summary>
public class Login_Check
{
    public static int Encrypt(string username,string password)
    {
         int Isvalid=-1;
        try
        {
            MD5CryptoServiceProvider encrypt = new MD5CryptoServiceProvider();
            byte[] EncryptedUsername = Encoding.ASCII.GetBytes(username);
            byte[] EncryptedPassword = Encoding.ASCII.GetBytes(password);
            EncryptedUsername = encrypt.ComputeHash(EncryptedUsername);
            EncryptedPassword = encrypt.ComputeHash(EncryptedPassword);

            string Enc_Username = Encoding.ASCII.GetString(EncryptedUsername);
            string Enc_Password = Encoding.ASCII.GetString(EncryptedPassword);

            Isvalid  = DataAccessLayer.ValidateUserCredentials(Enc_Username, Enc_Password);

            return Isvalid;
        }
        catch (Exception)
        {
            return Isvalid;
        }

    }
}